package version_1;

/**
 * @author 王子铮 11923040205
 */
public class Test1 {
    public static void main(String []args){

        //存放姓名的数组
        String[] name_list={"甲","乙","丙","丁","戊"};

        //存放对象的数组
        Person[] list =new Person[5];

        //随机生成5个对象，并存放在数组中
        for (int i=0;i<5;i++){
            int random= (int) (Math.random() * 5);
            switch (random){
                case 0:list[i]=new Person(name_list[i]);break;
                case 1:list[i]=new Student(name_list[i]);break;
                case 2:list[i]=new Employee(name_list[i]);break;
                case 3:list[i]=new Faculty(name_list[i]);break;
                case 4:list[i]=new staff(name_list[i]);break;
            }
        }

        //调用函数，打印相关信息
        printMessages(list);
    }

    /**打印对象信息*/
    public static void printMessages(Person[] persons){
        for (Person person : persons) {
            System.out.println(person.toString());
        }
    }
}

